﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class msg
    {
        public static dynamic cleanMsgBox(string username)
        {
            var sql = new Sql.SqlDataContext();
            var u = sql.User.FirstOrDefault(row => row.username.ToLower() == username.ToLower());
            if (u == null) return new
                {
                    success = false,
                    msg = "用户不存在"
                };
            sql.Message.DeleteAllOnSubmit(sql.Message.Where(row => row.to == u.username));
            sql.SubmitChanges();
            return new
            {
                success = true
            };
        }
    }
}